﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MvcEngine.Core.Services;
using System.Web.Mvc;
using MvcEngine.Mvc.Extensions;
using MvcEngine.Core;
using MvcEngine.Blog.Commands;
using MvcEngine.Core.Registry;
using MvcEngine.Mvc.Filters;
using MvcEngine.Blog.StarterSite.Controllers;
using MvcEngine.Mvc.Services;

namespace MvcEngine.Blog.Services
{
    public class BlogOverviewControlService : ControlServiceBase
    {
        public override void RegisterBackofficeRoutes(AreaRegistrationContext context)
        {
            context.MapMvcEngineRoute(
                "BlogPostOverviewSettings",
                "BackOffice/Blog/Overview/{ctrId}",
                new { controller = "BlogOverview", action = "OverviewSettings" },
                new string[] { "MvcEngine.Blog.BackOffice.Controllers" }
            );
        }

        public override IList<ControlCommand> GetCommands()
        {
            var commands = new List<ControlCommand>();
            commands.Add(new OverviewSettingsCommand() { Name = "Settings" });
            return commands;
        }

        public override void RegisterActionFilters(IActionFilterRegistry registry)
        {
            ControllerCriteria moduleCriteria = new ControllerCriteria();
            moduleCriteria.AddController(typeof(MvcEngine.Blog.BackOffice.Controllers.BlogOverviewController));
            registry.Add(new[] { moduleCriteria }, new ModuleActionFilter());
        }

        public override Type GetControllerType()
        {
            return typeof(BlogOverviewController);
        }

        public override string GetDefaultAction()
        {
            return "Overview";
        }
    }
}
